import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/music/playlist'
  },
  {
    path: '/music/playlist',
    name: 'playlist',
    component: () => import('@/views/playlist.vue'),
    meta: {
      KeepAlive: true,
      title: 'PlayList'
    }
  }
]

const router = new VueRouter({
  routes,
  linkActiveClass: 'active'
})

router.beforeEach((from, to, next) => {
  if(to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
